package com.nbsaas.boot.project.rest.convert;

import com.nbsaas.boot.project.api.domain.response.ProjectTaskCommentResponse;
import com.nbsaas.boot.project.data.entity.ProjectTaskComment;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
/**
 * 任务评论-实体对象转化成响应对象
 */

public class ProjectTaskCommentResponseConvert implements Converter<ProjectTaskCommentResponse, ProjectTaskComment> {

    @Override
    public ProjectTaskCommentResponse convert(ProjectTaskComment source) {
        ProjectTaskCommentResponse result = new ProjectTaskCommentResponse();
        BeanDataUtils.copyProperties(source, result);
        if (source.getTask() != null) {
            result.setTask(source.getTask().getId());
        }

        try {
            if (source.getTask() != null) {
                result.setTaskName(source.getTask().getName());
            }
        } catch (Exception ignored) {
        }

        if (source.getStoreState() != null) {
            result.setStoreStateName(String.valueOf(source.getStoreState()));
        }

        try {
            if (source.getUser() != null) {
                result.setUserName(source.getUser().getName());
            }
        } catch (Exception ignored) {
        }

        if (source.getUser() != null) {
            result.setUser(source.getUser().getId());
        }
        return result;
    }

}

